#include <SDL/SDL_image.h>
#include <SDL/SDL_ttf.h>
#include "Gomoku.h"
#include "MainWindow.h"
#include "PushButton.h"
#include "ButtonManager.h"
#include "PlayerTurnPrompter.h"
#include "MultiPlayerScreen.h"

MultiPlayerScreen::MultiPlayerScreen()
: GameScreen()
{
}

MultiPlayerScreen::~MultiPlayerScreen()
{
}

void MultiPlayerScreen::doEvents()
{	
	if (PlayerTurnPrompter::Instance().Count == 0)
	{
		if (ButtonManager::Instance().update() == false)
			return ;
		for (int i = 0; i < 2; i++)
		{
			if (Gomoku::Instance().getPlayers()[i].Winner == true)
			{
				PlayerTurnPrompter::Instance().setText("Game reinitialized", COLOR_BLACK);
				PlayerTurnPrompter::Instance().Count = 50;
				Gomoku::Instance().reset();
				return ;
			}
		}
		if (Gomoku::Instance().CurrentPlayer->Winner == false)
		{
			m_board.setCanMovePieces(m_checkBoxMovePieces->isChecked());
			m_board.setCanRemovePieces(m_checkBoxCanRemovePiece->isChecked());
			m_board.doEvents();
			if (Gomoku::Instance().Arbiter.RuleThree() == true)
				m_currentInfos = INFOS_RULE_THREE;
			else
				m_currentInfos = INFOS_WAITING;
		}
	}
	this->GameScreen::doEvents();
}
